package com.mnsq.im.conf;

import com.mnsq.im.server.TkServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author Administrator
 * @date 2019/4/25 0025
 */
@ComponentScan(basePackages = "com.mnsq.im")
@Component
public class StartServer {
    @Value("${server.port}")
    private int port;

    @Autowired
    private TkServer tkServer;

    @PostConstruct
    public void start() {
        tkServer.setPort(port);
        ExecutorService executorService = Executors.newSingleThreadExecutor();
        executorService.submit(tkServer);
    }
}
